//
//  TMButtons.swift
//  ArchitectGenerics
//
//  Created by 姚胜龙 on 2017/6/8.
//  Copyright © 2017年 姚胜龙. All rights reserved.
//

import UIKit

//请求者（模拟按钮的点击）

class TMButtons {
    //持有命令
    private var leftCommand:TMLeftCommand?
    private var rightCommand:TMRightCommand?
    private var fastDownCommand:TMFastDownCommand?
    private var transformCommand:TMTransformCommand?
    //初始化
    init(leftCommand:TMLeftCommand,rightCommand:TMRightCommand,fastDownCommand:TMFastDownCommand,transformCommand:TMTransformCommand)
    {
        self.fastDownCommand = fastDownCommand
        self.leftCommand = leftCommand
        self.rightCommand = rightCommand
        self.transformCommand = transformCommand
    }

    //创建执行命令的方法
    func toLeft() {
        self.leftCommand?.execute()
    }
    func toRight() {
        self.rightCommand?.execute()
    }

    func fastDown() {
        self.fastDownCommand?.execute()
    }
    func transform() {
        self.transformCommand?.execute()
    }
}
